package net.wenku8.reader.view.user

import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.lifecycle.viewmodel.compose.viewModel
import net.wenku8.reader.LocalNavController
import net.wenku8.reader.ui.lite.LiteButton
import net.wenku8.reader.ui.lite.LiteCheckBox
import net.wenku8.reader.ui.lite.LiteInput
import net.wenku8.reader.ui.lite.LitePanel
import net.wenku8.reader.ui.lite.LitePassword

@Composable
fun Login() {
    val loginViewModel = viewModel<LoginViewModel>()
    val navController = LocalNavController.current
    LaunchedEffect(Unit) {
        loginViewModel.initData()
    }
    LitePanel(
        hostState = loginViewModel.hostState,
        title = "文库登录",
        backNav = true
    ) {
        Column{
            LiteInput("用户名或邮箱", loginViewModel.username)
            LitePassword("密码", loginViewModel.password)
            LiteCheckBox( "记住密码", loginViewModel.rememberPassword)
            LiteButton( "登录") { loginViewModel.onLogin(navController) }
        }
    }

}

